package com.atguigu05._super.exer3;

/**
 * ClassName: Account
 * Package: com.atguigu05._super.exer3
 * Description:
 *
 * @Author 姜
 * @Create 2023/11/22 11:34
 * @Version 1.0
 */
public class Account {
    private int id;
    private double balance;
    private double annualInterestRate; // 年利率

//    public Account() {
//    }

    public Account(int id, double balance, double annualInterestRate) {
        this.id = id;
        this.balance = balance;
        this.annualInterestRate = annualInterestRate;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public double getAnnualInterestRate() {
        return annualInterestRate;
    }

    public void setAnnualInterestRate(double annualInterestRate) {
        this.annualInterestRate = annualInterestRate;
    }

    /**
     * 获取月利率
     *
     * @return
     */
    public double getMonthlyInterest() {
        return annualInterestRate / 12;
    }

    /**
     * 取钱
     *
     * @param amount 要取的金额
     */
    public void withdraw(double amount) {
        if (balance >= amount) {
            balance -= amount;
        } else {
            System.out.println("有多少钱心里没点逼数吗");
        }
    }

    /**
     * 存钱
     *
     * @param amount 要存的金额
     */
    public void deposit(double amount) {
        if (amount > 0) {
            balance += amount;
        }
    }
}
